/*
* berton
*/
package com.pitop.products.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

import com.pitop.products.api.ProductsSoldFeignApi;
import com.pitop.core.exceptions.ProductsSoldException;
import com.pitop.core.exceptions.BaseException;
import com.pitop.core.entity.Page;
import com.pitop.products.entity.ProductsSold;


/**
 * 已销售设备
 * @author berton
 */
@Service("productsSoldSVImpl")
@Slf4j
public class ProductsSoldSVImpl {

    @Autowired
    private ProductsSoldFeignApi productsSoldFeignApi;

    /**
     * 加载一个对象ProductsSold
     * @param id * @param code 编码
     * @return ProductsSold
     */
    public ProductsSold load(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new ProductsSoldException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return productsSoldFeignApi.load(id,code);
    }
    /**
     * 加载一个对象ProductsSold 通过id
     * @param id 
     * @return ProductsSold
     */
    public ProductsSold loadById(java.lang.Long id) {
        if(id==null){
            throw new ProductsSoldException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return productsSoldFeignApi.loadById(id);
    }

    /**
     * 加载一个对象ProductsSold 通过code
     * @param code 编码
     * @return ProductsSold
     */
    public ProductsSold loadByCode(java.lang.String code) {
        if(code==null){
            throw new ProductsSoldException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return productsSoldFeignApi.loadByCode(code);
    }


    /**
     * 删除对象ProductsSold
     * @param id * @param code 编码
     * @return ProductsSold
     */
    
    public void delete(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new ProductsSoldException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        productsSoldFeignApi.delete(id,code);
    }



    /**
     * 查询ProductsSold分页
     *
     * @param productsSold  对象
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<ProductsSold>
     */
    public List<ProductsSold> list(ProductsSold productsSold, int curPage,int pageSize) {
        return productsSoldFeignApi.list(productsSold, curPage,pageSize);
    }

    /**
     * 查询ProductsSold分页
     *
     * @param id  * @param code  编码
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<ProductsSold>
     */
    public List<ProductsSold> list(java.lang.Long id,java.lang.String code,int curPage, int pageSize) {
        if (curPage < 0) {
           curPage = 1;
        }

        if (pageSize < 0) {
            pageSize = Page.limit;
        }

        ProductsSold productsSold=new ProductsSold();
        productsSold.setId(id);
        productsSold.setCode(code);

        return productsSoldFeignApi.list(productsSold,curPage,pageSize);
    }


    public int count(java.lang.Long id,java.lang.String code) {
        return productsSoldFeignApi.count(id,code);
    }


    public int count(ProductsSold productsSold) {
        return productsSoldFeignApi.count(productsSold);
    }


    /**
     * 保存
     *
     * @param productsSold 实体
     * @throws BaseException
     */
    public void save(ProductsSold productsSold) {
        if(productsSold==null){ throw new ProductsSoldException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        productsSoldFeignApi.build(productsSold);
    }

    /**
     * 更新
     *
     * @param productsSold 实体
     * @throws BaseException
     */
    public void modify(ProductsSold productsSold) {
        if(productsSold==null){ throw new ProductsSoldException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        productsSoldFeignApi.modify(productsSold);
    }

}
